<?php
/*
----------------------------------------------------------------------
file:   hc_function.php
time:   2008.09
author: joecen
site:   http://www.joecen.com/hcacti/
----------------------------------------------------------------------
*/



function write_file($filename,$info,$type="w"){
	$fp = @fopen($filename,$type);
	if($fp){
		fwrite($fp,$info);
		fclose($fp);
	}
}

function get_host_info($hostname){
	global $config;
	$host_info = db_fetch_assoc("
	        select d.name, c.local_data_id, c.data_source_path 
	        from host as a, data_local as b , 
	        data_template_data as c , data_template as d 
	        where a.hostname='".$hostname."' 
	        and a.id=b.host_id 
	        and b.id=c.local_data_id
	        and b.data_template_id=d.id");
	
	foreach($host_info as $temp){
		if(empty($temp["data_source_path"])){
			$temp["data_source_path"] = generate_data_source_path($temp["local_data_id"]);
		}
	        $host_file[$temp['name']]["path"] = preg_replace('/<path_rra>/',$config["rra_path"],$temp["data_source_path"]);
	        $host_file[$temp['name']]["local_data_id"] = $temp["local_data_id"];
	}
	return $host_file;	
}

?>
